package br.com.portalecbahia.customize;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import br.com.portalecbahia.R;
import br.com.portalecbahia.model.Share;

public class ShareListAdapter extends BaseAdapter {
	private LayoutInflater li;
	private ArrayList<Share> mItems;
	
	public ShareListAdapter(Context context, ArrayList<Share> items) {
		mItems = items;
		li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	@Override
	public int getCount() {
		return mItems.size();
	}

	@Override
	public Object getItem(int position) {
		return mItems.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		convertView = li.inflate(R.layout.item_list_share, null);
			
		ImageView icon = (ImageView) convertView.findViewById(R.id.icon);
		TextView title = (TextView) convertView.findViewById(R.id.title);
		
		
		Share item = mItems.get(position);
		
		icon.setImageResource(item.getIconResource());
		title.setText(item.getTitle());
		
		return convertView;
	}
	
	

}
